/*
 * 2.3.cpp
 *
 *  Created on: 2012-5-17
 *      Author: jawinton
 */


#include <iostream>
#include <cstring>
using namespace std;

int main (void) {
	int trees,n;
	cin >> trees >> n;
	trees += 1;
	bool *arr = new bool[trees];
	if(arr == NULL) {
		cerr << "new error" << endl;
		return -1;
	}
	memset(arr, 0, sizeof(bool));
	for (int i=0; i<n; i++) {
		int a, b;
		cin >> a >> b;
		memset(arr+a, 1, b-a+1);
	}
	int total = 0;
	for (int i = 0; i < trees-1; i++) {
		total += arr[i];
	}
	cout << trees-total << endl;
	delete arr;
	return 0;
}
